Skip to content

DM-54869: Add option to specify alias for the host name in db-auth#142

Merged
andy-slac merged 3 commits into
mainfrom
tickets/DM-54869
May 18, 2026
Merged

DM-54869: Add option to specify alias for the host name in db-auth#142
andy-slac merged 3 commits into
mainfrom
tickets/DM-54869

Conversation

@andy-slac

Copy link
Copy Markdown
Collaborator

Cassandra connection config class added dbauth_alias field which is used
as an additional host name when checking credentials in db-auth.yaml.
This alias is checked first, if not found then all contact point hosts
are checked as usual. The alias entry in db-auth.yaml does not need
to specify port number, and it looks like (can also include username@
as usual):

- url: cassandra://alias_name/
  username: ...
  password: ...

The apdb-cli create-cassandra command adds option --dbauth-alias which
defines the alias at database creation time and stores it in the resulting
config file.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for a Cassandra “db-auth alias” that can be used as an additional (higher-priority) hostname when resolving credentials from db-auth.yaml, and exposes this via the apdb-cli create-cassandra command.

Changes:

  • Add dbauth_alias to ApdbCassandraConnectionConfig and thread it through ApdbCassandra.init_database.
  • Update Cassandra session auth lookup to try the alias first (without a port) before falling back to contact points.
  • Add unit tests covering db-auth credential matching behavior (including alias cases) and introduce a small test utility for temporary env var overrides.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_apdbCassandra.py Adds credential-resolution tests for db-auth matching and new alias behavior.
python/lsst/dax/apdb/tests/utils.py Adds modified_environment context manager used by tests.
python/lsst/dax/apdb/cli/options.py Exposes --dbauth-alias via argparse options derived from Pydantic fields.
python/lsst/dax/apdb/cassandra/sessionFactory.py Tries dbauth_alias first (no port) when resolving DbAuth credentials.
python/lsst/dax/apdb/cassandra/config.py Introduces dbauth_alias config field and its help/description text.
python/lsst/dax/apdb/cassandra/apdbCassandra.py Adds dbauth_alias parameter to init_database and documents it.
.pre-commit-config.yaml Bumps pre-commit hook revisions (pre-commit-hooks and ruff).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread python/lsst/dax/apdb/cassandra/config.py Outdated
Comment thread python/lsst/dax/apdb/cassandra/apdbCassandra.py
@codecov

codecov Bot commented May 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.54545% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.83%. Comparing base (be40082) to head (5d1119c).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
python/lsst/dax/apdb/cassandra/apdbCassandra.py 0.00% 1 Missing and 1 partial ⚠️
python/lsst/dax/apdb/cassandra/sessionFactory.py 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #142      +/-   ##
==========================================
+ Coverage   84.66%   84.83%   +0.16%     
==========================================
  Files          73       73              
  Lines        7331     7385      +54     
  Branches      845      847       +2     
==========================================
+ Hits         6207     6265      +58     
+ Misses        890      883       -7     
- Partials      234      237       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@andy-slac andy-slac force-pushed the tickets/DM-54869 branch 2 times, most recently from 3b75b61 to bd08564 Compare May 7, 2026 16:33
andy-slac added 2 commits May 7, 2026 09:56
Cassandra connection config class added `dbauth_alias` field which is used
as an additional host name when checking credentials in `db-auth.yaml`.
This alias is checked first, if not found then all contact point hosts
are checked as usual. The alias entry in `db-auth.yaml` does not need
to specify port number, and it looks like (can also include `username@`
as usual):

    - url: cassandra://alias_name/
      username: ...
      password: ...

The `apdb-cli create-cassandra` command adds option `--dbauth-alias` which
defines the alias at database creation time and stores it in the resulting
config file.
@andy-slac andy-slac force-pushed the tickets/DM-54869 branch from 7f91c2a to 5d1119c Compare May 7, 2026 16:56
@andy-slac andy-slac merged commit 8573ff4 into main May 18, 2026
21 checks passed
@andy-slac andy-slac deleted the tickets/DM-54869 branch May 18, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants